package com.example.demo0

import com.example.util.p


data class ApplyEvent2(val money:Int,val title:String)

val groupLeader = {
    val definetAt:(ApplyEvent2)->Boolean = {it.money <= 200}
    val handler: (ApplyEvent2)->Unit = {
        p("Group Leader handled application:${it.title}")
    }
    PartialFunction(definetAt,handler)
}()

val president = {
    val definetAt:(ApplyEvent2)->Boolean={it.money<=500}
    val handler : (ApplyEvent2)->Unit = {
        p("President handled application:${it.title}")
    }
    PartialFunction(definetAt,handler)
}()

val college = {
    val definetAt:(ApplyEvent2)->Boolean={true}
    val handler: (ApplyEvent2)->Unit={
        when{
            it.money > 1000 -> p("College:This application is refused")
            else -> p("College handled application:${it.title}")
        }
    }
    PartialFunction(definetAt,handler)
}()












